package Receive;

import java.io.IOException;

public class Search_Report extends Receive_Packet {

	public int store_code;
	float avg_grade;
	public Opinion[] op;
	public int op_count;

	public Search_Report(byte[] packet) {
		super(packet);
	}

	public void get_code(byte[] packet) {
		byte[] temp = new byte[4];
		System.arraycopy(packet, 5, temp, 0, 4);
		this.store_code = byteToint(temp);
	}

	public void get_grade(byte[] packet) {
		byte[] temp = new byte[4];
		System.arraycopy(packet, 9, temp, 0, 4);
		this.avg_grade = byteTofloat(temp);
	}

	public void get_Opinion(byte[] packet) throws IOException {
		int temp_length = packet.length - 13;
		byte[] temp = new byte[temp_length];
		System.arraycopy(packet, 13, temp, 0, temp_length);
		String temp_string = new String(temp, "euc-kr");
		String[] opinions = temp_string.split("\r\n");

		op = new Opinion[opinions.length / 5];
		for (int i = 0; i < opinions.length / 5; i++) {
			op[i] = new Opinion();
		}

		for (int i = 0; i < opinions.length / 5; i++) {
			op[i].num = opinions[5 * i];
			op[i].nick = opinions[5 * i + 1];
			op[i].opinion = opinions[5 * i + 2];
			op[i].like = opinions[5 * i + 3];
			op[i].unlike = opinions[5 * i + 4];
		}

	}

}
